﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fuse8.ContentManagementFramework.BizFacade.Services;
using Fuse8.ContentManagementFramework.Domain.Special;
using Fuse8.DomainFramework.Common;
using Fuse8.DomainFramework.Common.Locator;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.ContentManagementFramework.BizFacade
{
    public static class CmsSearchServiceConfiguration
    {
        private static List<string> _areas = new List<string>();

        public static void RegisterSearchArea<TEntity>(string areaName, ICmsSearchService searchService)
            where TEntity: Int32EntityObject, new ()
        {
            Guard.ArgumentNotNull(areaName, "areaName");
            Guard.ArgumentNotNull(searchService, "searchService");

            lock (_areas)
            {
                if (!_areas.Contains(areaName))
                    _areas.Add(areaName);

                DependencyServiceLocator.Current.Register<ICmsSearchService>(areaName, searchService);
            }
        }

        public static IEnumerable<string> SearchAreas { get { return _areas; } }
    }
}
